home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
smus.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
2KB
|
103 lines
#include <exec/types.h>
#include <exec/memory.h>
#include <libraries/dos.h>
struct SScoreHeader
{
UWORD tempo;
UBYTE volume;
UBYTE ctTrack;
} *sh;
struct RefInstrument
{
UBYTE reg;
UBYTE type;
UBYTE data1,data2;
char name[];
} *ri;
struct FileHandle *fh;
UBYTE mem[4096];
ULONG ChunkLen;
LONG i,j,k,l;
UBYTE FoundChunk;
UBYTE *Track[50];
ULONG TrackLen[50];
UBYTE tc;
VOID main()
{
fh=Open("DH0:Musik/Aegis Sonix/Scores/The End.smus",MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&mem,12);
if(!(strncmp(&mem,"FORM",4)))
{
if(!(strncmp(&mem[8],"SMUS",4)))
{
printf("Reading IFF-SMUS file...\n");
}
tc=0;
/* -------------------------------------------------------------- */
i=Read(fh,&mem,8);
while(i==8)
{
ChunkLen=mem[4]*16777216+mem[5]*65536+mem[6]*256+mem[7];
FoundChunk=FALSE;
if(!(strncmp(&mem,"SHDR",4)))
{
FoundChunk=TRUE;
sh=&mem;
Read(fh,sh,ChunkLen);
printf("Header:\n");
printf(" Tempo: %ld\n",sh->tempo);
printf(" Volume: %ld\n",sh->volume);
printf(" ctTrack: %ld\n",sh->ctTrack);
}
else if(!(strncmp(&mem,"INS1")))
{
FoundChunk=TRUE;
ri=&mem;
Read(fh,ri,ChunkLen);
mem[ChunkLen]=0x00;
printf("Instrument %ld: %s\n",ri->reg,&ri->name);
}
else if(!(strncmp(&mem,"TRAK")))
{
FoundChunk=TRUE;
Track[tc]=AllocMem(ChunkLen,MEMF_CLEAR|MEMF_PUBLIC);
if(Track[tc]!=NULL)
{
Read(fh,Track[tc],ChunkLen);
TrackLen[tc]=ChunkLen;
}
else exit(0);
printf("Track #%ld %ld Bytes\n",tc,ChunkLen);
tc++;
}
if(FoundChunk==FALSE)
{
printf("%c%c%c%c\n",mem[0],mem[1],mem[2],mem[3]);
Seek(fh,ChunkLen,OFFSET_CURRENT);
}
if(ChunkLen & 1) Seek(fh,1,OFFSET_CURRENT);
i=Read(fh,&mem,8);
}
/* -------------------------------------------------------------- */
}
for(i=0;i<10;i++)
{
if(Track[i]!=NULL) FreeMem(Track[i],TrackLen[i]);
}
Close(fh);
}
}